#ifndef AER_RENDERTEXUTRE_HPP_
#define AER_RENDERTEXUTRE_HPP_

#include "aerRenderTarget.hpp"


namespace aer {

class Texture;

/// ===============================
/// + Render a scene in a texture +
/// ===============================
class RenderTexture : public RenderTarget
{
  protected:
    const Texture *m_pOutput;
    
  public:
    RenderTexture() 
        : RenderTarget(),
          m_pOutput(NULL)
    {}
    
    
    bool setup(const aer::Texture *pOutput);
    
    void begin();
    void end();
    
    const aer::Texture* getTexture() { return m_pOutput; }
};


/// ===================================================
/// + RenderTexture with a double buffering mechanism +
/// ===================================================
class RenderTextureDB : public RenderTarget
{
  private:
    const Texture *m_pOutput[2];
    bool m_out;
    bool m_bAutoSwap;
  
  
  public:
    RenderTextureDB()
        : RenderTarget(),
          m_out(false),
          m_bAutoSwap(false)
    {
      m_pOutput[0] = NULL;
      m_pOutput[1] = NULL;
    }
    
    
    bool setup(const aer::Texture *pTex1, const aer::Texture *pTex2);
    
    void begin();
    void end();
        
    void swap() { m_out = !m_out; }
    
    const aer::Texture* getTexture() { return m_pOutput[m_out]; }
};

} // aer


#endif //AER_RENDERTEXUTRE_HPP_
